home *** CD-ROM | disk | FTP | other *** search
- ; this file contain the self-detection part, the install and deinstall part !
- ; don't stay in memory after installation !!!
-
- DetectPrg PROC
- ; ne pas retomber sur notre MCB (prog) !!!
- MOV AX,ES ; debut du PSP
- DEC AX ; debut du MCB !!!
- MOV ES,AX ; ES=ES-1
- MOV DI,5 ; MCB = 16 octets -1-2-2
- MOV CX,11
- CLD
- XOR AL,AL
- REP STOSB ; mise a zero !!! du MCB du prog ... make it invisible !!!
-
- ; check if already in memory ... scan MCB list !!!
- MOV AH,52h
- INT 21h
- MOV AX,ES
- DEC AX
- MOV ES,AX ; ES=ES-1
- MOV ES,WORD PTR ES:[BX+14] ; ptr vers 1er MCB ;
-
- Search: CMP WORD PTR ES:12,TsrId1*256+0 ; 0 pour NULL
- JNE NextMcb
- CMP WORD PTR ES:14,TsrId3*256+TsrId2
- JNE NextMcb
- STC
- RETN ; on est deja en memoire
-
- NextMCB: CMP BYTE PTR ES:0,'Z'
- JE PutPrgInMem ; c'est le dernier et on est pas dans la liste
- MOV AX,ES
- INC AX
- ADD AX,WORD PTR ES:3
- MOV ES,AX ; ES:0 MCB suivant
- JMP Search
-
- PutPrgInMem: CLC
- RETN
- DetectPrg ENDP
-
-
- RemovePrg PROC ; on entry ES = seg du MCB (see above)
-
- CLI
-
- MOV WORD PTR ES:12,0 ; chipote au MCB du prg resident
- MOV WORD PTR ES:14,0 ; remise a zero
-
- MOV AX,ES
- INC AX
- MOV ES,AX ; ES=ES+1
- MOV AH,49h
- INT 21h ; remove from mem resident prg
-
- ; Restaurer les vect. d'origines !!!
-
- MOV BX,OFFSET OldInt8Ofs
- MOV DX,WORD PTR ES:[BX]
- MOV DS,WORD PTR ES:[BX+2]
- MOV AX,2508h
- INT 21h
-
- MOV BX,OFFSET OldInt9Ofs ; d'abord l'offs puis le seg (en +2)
- MOV DX,WORD PTR ES:[BX]
- MOV DS,WORD PTR ES:[BX+2] ; il y avait plus simple mais ce @]`\[\[ d'assembleur ne voulait pas
- MOV AX,2509h
- INT 21h
-
- MOV BX,OFFSET OldInt13Ofs
- MOV DX,WORD PTR ES:[BX]
- MOV DS,WORD PTR ES:[BX+2]
- MOV AX,2513h
- INT 21h
-
- MOV BX,OFFSET OldInt28Ofs
- MOV DX,WORD PTR ES:[BX]
- MOV DS,WORD PTR ES:[BX+2]
- MOV AX,2528h
- INT 21h
-
- PUSH CS
- POP DS
-
- STI
-
- PrintMac RemoveStr
- MOV AX,4C00h ; error n° 0 ... OK
- INT 21h ; Finito !
- RemovePrg ENDP
-
-
- InstallPrg PROC
- CLI
-
- PUSH CS
- POP ES
-
- ; liberer la memoire correspondante a notre envir
- MOV ES,WORD PTR ES:2Ch ; seg de notre envir
- MOV AH,49h
- INT 21h ; envir = Dead !!!
-
- PUSH CS
- POP ES
-
- MOV AX,ES
- DEC AX
- MOV ES,AX ; ES=ES-1
- MOV WORD PTR ES:12,TsrId1*256+0 ; put IdString in the MCB
- MOV WORD PTR ES:14,TsrId3*256+TsrId2
-
- PUSH CS
- POP DS
-
- MOV AX,3508h ; BIOS timer
- INT 21h
- MOV OldInt8Ofs,BX
- MOV OldInt8Seg,ES
- MOV AX,2508h
- MOV DX,OFFSET NewInt8
- INT 21h ; put new handler
-
- MOV AX,3509h ; BIOS kbd
- INT 21h
- MOV OldInt9Ofs,BX
- MOV OldInt9Seg,ES
- MOV AX,2509h
- MOV DX,OFFSET NewInt9
- INT 21h ; put new handler
-
- MOV AX,3513h ; BIOS I/O
- INT 21h
- MOV OldInt13Ofs,BX
- MOV OldInt13Seg,ES
- MOV AX,2513h
- MOV DX,OFFSET NewInt13
- INT 21h ; put new handler
-
- MOV AX,3528h ; DOS Idle Int.
- INT 21h
- MOV OldInt28Ofs,BX
- MOV OldInt28Seg,ES
- MOV AX,2528h
- MOV DX,OFFSET NewInt28
- INT 21h ; put new handler
-
- MOV AH,34h
- INT 21h ; return in ES:BX INDOS flag
- MOV IndosPtrOfs,BX
- MOV IndosPtrSeg,ES
-
- STI
-
- PrintMac InstallStr
-
- MOV DX,(EndOfResident-Start+100h+15) SHR 4 ; = l'age du capitaine
- MOV AX,3100h ; error n° 0 ... OK
- INT 21h ; TSR !!!
- InstallPrg ENDP